const { override, fixBabelImports, addWebpackAlias } = require('customize-cra')
const path = require('path')

module.exports = override(
  // 针对antd 实现按需打包：根据import来打包 (使用babel-plugin-import)
  fixBabelImports('import', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: true //自动打包相关的样式 默认为 style:'css'
  }),
  //增加路径别名的处理
  addWebpackAlias({
    '@': path.resolve('src')
  }),
  config => {
    //暴露webpack的配置
    // 去掉打包生产map 文件
    // config.devtool = config.mode === 'development' ? 'cheap-module-source-map' : false;
    if (process.env.NODE_ENV === 'production') config.devtool = false

    // 设置publicPath
    config.output.publicPath = './'

    return config
  }
)
